package com.bjtech.web.action.management;

import java.util.List;

import com.bjtech.dao.BaseBuildingInfoDao;
import com.bjtech.dao.BaseUnitInfoDao;
import com.bjtech.domain.BaseBuildingInfo;
import com.bjtech.domain.BaseUnitInfo;
import com.bjtech.domain.query.BaseBuildingInfoQuerySpec;
import com.bjtech.domain.query.BaseUnitInfoQuerySpec;
import com.bjtech.web.action.LyheatBaseAction;

public class BaseUnitInfoAction extends LyheatBaseAction {

	private static final long serialVersionUID = 1L;
	private BaseUnitInfoDao baseUnitInfoDao;
	private BaseUnitInfoQuerySpec selectBean;
	
	private BaseBuildingInfoDao baseBuildingInfoDao;
	private List buidList;
	
	public void prepare() throws Exception {

	}
	
	public BaseUnitInfoAction() throws Exception{
		model = new BaseUnitInfo();
		selectBean = new BaseUnitInfoQuerySpec();
	}
	
	public void setBaseUnitInfoDao(BaseUnitInfoDao baseUnitInfoDao) {
		this.baseUnitInfoDao = baseUnitInfoDao;
	}

	public String execute(){
		return this.list();
	}
	
	public String list(){
		buidList = baseBuildingInfoDao.selectEntityList(new BaseBuildingInfo(), new BaseBuildingInfoQuerySpec());
		selectBean.queryParamString();
		list = this.baseUnitInfoDao.selectEntityPaginatedList(new BaseUnitInfo(),selectBean);
		return "list";
	}
	
	public String add(){
		buidList = baseBuildingInfoDao.selectEntityList(new BaseBuildingInfo(), new BaseBuildingInfoQuerySpec());
		return "edit";
	}
	
	public String save(){
		BaseUnitInfo entity = (BaseUnitInfo)model;
		if(entity.getId()==null){
			baseUnitInfoDao.insertEntity(entity);
		}else{
			baseUnitInfoDao.updateEntity(entity);
		}
		return "success";
	}
	
	public String edit(){
		model = this.baseUnitInfoDao.selectEntity(new BaseUnitInfo(),id);
		buidList = baseBuildingInfoDao.selectEntityList(new BaseBuildingInfo(), new BaseBuildingInfoQuerySpec());
		return "edit";
	}

	public String view(){
		model = this.baseUnitInfoDao.selectEntity(new BaseUnitInfo(),id);
		return "view";
	}
	
	public String delete(){
		model = this.baseUnitInfoDao.deleteEntity(new BaseUnitInfo(),id);
		return "success";
	}
	
	public BaseUnitInfoQuerySpec getSelectBean() {
		return selectBean;
	}

	public void setSelectBean(BaseUnitInfoQuerySpec selectBean) {
		this.selectBean = selectBean;
	}

	public BaseBuildingInfoDao getBaseBuildingInfoDao() {
		return baseBuildingInfoDao;
	}

	public void setBaseBuildingInfoDao(BaseBuildingInfoDao baseBuildingInfoDao) {
		this.baseBuildingInfoDao = baseBuildingInfoDao;
	}

	public List getBuidList() {
		return buidList;
	}

	public void setBuidList(List buidList) {
		this.buidList = buidList;
	}

	public BaseUnitInfoDao getBaseUnitInfoDao() {
		return baseUnitInfoDao;
	}
}
